package com.ai.controller.made;


import com.ai.annotation.EnterPathParamLog;
import com.ai.common.CommonResponse;
import com.ai.entity.made.camera.CameraBO;
import com.ai.entity.made.page.CameraPage;
import com.ai.entity.made.page.MaintenancePersonnelInformationPage;
import com.ai.model.dto.MaintenancePersonnelInformationDto;
import com.ai.service.made.IMaintenancePersonnelInformationService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;

/**
 * 检修人员信息接口
 * @author jiaok
 * @since 2025-01-08
 */
@RestController
@RequestMapping("/maintenance-personnel-information")
public class MaintenancePersonnelInformationController {

    @Resource
    private IMaintenancePersonnelInformationService iMaintenancePersonnelInformationService;


    @ApiOperation("分页查询")
    @PostMapping("list")
    @EnterPathParamLog
    public IPage selectByPage(@RequestBody MaintenancePersonnelInformationPage maintenancePersonnelInformationPage) {
        return iMaintenancePersonnelInformationService.selectByPage(maintenancePersonnelInformationPage);
    }

    @ApiOperation("添加检修人员信息")
    @PostMapping("add")
    @EnterPathParamLog
    public CommonResponse addMaintenancePersonnelInformation(@RequestBody MaintenancePersonnelInformationDto maintenancePersonnelInformationDto) {
        CommonResponse resultData = iMaintenancePersonnelInformationService.addMaintenancePersonnelInformation(maintenancePersonnelInformationDto);
        return resultData;
    }

    @ApiOperation("删除检修人员信息")
    @PostMapping("delete")
    @EnterPathParamLog
    public CommonResponse deleteMaintenancePersonnelInformation(@RequestBody MaintenancePersonnelInformationDto maintenancePersonnelInformationDto) {
        CommonResponse resultData = iMaintenancePersonnelInformationService.deleteMaintenancePersonnelInformation(maintenancePersonnelInformationDto);
        return resultData;
    }

    @ApiOperation("修改检修人员信息")
    @PostMapping("modifyInfo")
    @EnterPathParamLog
    public CommonResponse modifyInfoMaintenancePersonnelInformation(@RequestBody MaintenancePersonnelInformationDto maintenancePersonnelInformationDto) {
        CommonResponse resultData = iMaintenancePersonnelInformationService.modifyInfoMaintenancePersonnelInformation(maintenancePersonnelInformationDto);

        return resultData;
    }


    @ApiOperation("导入检修人员信息")
    @PostMapping("importMaintenancePersonExcel")
    public CommonResponse importMaintenancePersonExcel(MultipartFile multipartFile) throws IOException {
        if (multipartFile.isEmpty()) {
            return CommonResponse.error("导入文件不能为空");
        }
        return iMaintenancePersonnelInformationService.importMaintenancePersonExcel(multipartFile);
    }


}
